/*   
 * Copyright @ JuCheap All rights reserved.
 * 
 * 功能描述:基础服务接口文件
 * 作者: jucheap
 * 时间: 03/13/2019 17:13:01
 */
using JuCheap.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace JuCheap.Core.IService
{	
	/// <summary>
	/// 基础服务接口
	/// </summary>	
	public interface IBaseService<TModel, TFilter, TEntity>
	{
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">数据模型</param>
        /// <returns></returns>
        Task<string> InsertAsync(TModel entity);

        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="list">模型集合</param>
        Task BatchInsertAsync(List<TModel> list);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model">数据模型</param>
        /// <returns></returns>
        Task UpdateAsync(TModel model);

        /// <summary>
        /// 删除指定主键id的数据(逻辑删除)
        /// </summary>
        /// <param name="keyId">主键Id</param>
        /// <returns></returns>
        Task DeleteAsync(string keyId);

        /// <summary>
        /// 批量条件删除(逻辑删除)
        /// </summary>
        /// <param name="keyIds">主键Id集合</param>
        /// <returns></returns>
        Task DeleteAsync(IList<string> keyIds);

        /// <summary>
        /// 根据主键查询实体
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        Task<TModel> FindAsync(object keyValue);

        /// <summary>
        /// 根据条件查询实体
        /// </summary>
        /// <param name="predicate">条件表达式</param>
        /// <returns></returns>
        Task<TModel> FindAsync(Expression<Func<TEntity, bool>> predicate);

        /// <summary>
        /// 根据条件查询实体集合
        /// </summary>
        /// <param name="predicate">条件表达式</param>
        /// <returns></returns>
        Task<List<TModel>> FindListAsync(Expression<Func<TEntity, bool>> predicate);

        /// <summary>
        /// 根据条件查询是否存在指定的数据
        /// </summary>
        /// <param name="predicate">条件表达式</param>
        /// <returns></returns>
        Task<bool> ExistsAsync(Expression<Func<TEntity, bool>> predicate);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="filter">分页条件</param>
        /// <param name="predicate">查询条件</param>
        /// <returns></returns>
        Task<PagedResult<TModel>> QueryPagesAsync(BaseCondition filter, Expression<Func<TFilter, bool>> predicate);
    }
}
	